package com.tools.automatic_clock.service;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.springframework.stereotype.Service;

@Service
public class seleniumApi {//                           驱动名称            业务名
    public static WebDriver driver(String url, String drivername, String business) {
        //必要代码
        //设置JVM名叫webdriver.chrome.driver的系统属性，值为驱动路径
        //src/main/resources/chromedriver.exe ../../bin/chromedriver
        System.setProperty("webdriver.chrome.driver", "src/main/resources/chromedriver.exe");
        ChromeDriver chromeDriver = new ChromeDriver();
        try {
            //获取url
            ((WebDriver) chromeDriver).get(url);
            return chromeDriver;
            //------
        } catch (Exception e) {
            System.out.println("error");
        }
        return null;
    }
}
